home *** CD-ROM | disk | FTP | other *** search
- /*
- ** launcher.c
- **
- ** this is a simple notification program
- **
- ** launch it on the CD³² and have twin running!
- **
- ** for example:
- **
- ** run <>NIL: launcher RAM:remote
- ** twin SER 300000
- **
- ** after that copy from the other computer somthing
- ** executable to ~RAM:remote - it will be started ;-)
- **
- ** written by Daniel Balster
- */
-
- #include <exec/exec.h>
- #include <dos/dos.h>
- #include <dos/notify.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
-
- char *version = "$VER: launcher v1.0.0";
-
- #define TEMPLATE "NAME/A"
-
- struct {
- STRPTR name;
- ULONG pad[15];
- } args;
-
- int main(void)
- {
- struct RDArgs *rdargs;
- struct NotifyRequest *nr;
- ULONG signals, signal;
- BOOL quit = FALSE;
-
- if (rdargs = ReadArgs(TEMPLATE,(LONG*)&args,NULL))
- {
- if (nr = (struct NotifyRequest*) AllocVec (sizeof(struct NotifyRequest),MEMF_PUBLIC|MEMF_CLEAR))
- {
- if (signal = AllocSignal(-1))
- {
- nr->nr_Name = args.name;
- nr->nr_Flags = NRF_SEND_SIGNAL;
- nr->nr_stuff.nr_Signal.nr_Task = FindTask( NULL );
- nr->nr_stuff.nr_Signal.nr_SignalNum = signal;
-
- StartNotify (nr);
-
- while (!quit)
- {
- signals = Wait ((1L<<signal)|SIGBREAKF_CTRL_C);
-
- if( signals & SIGBREAKF_CTRL_C ) quit = TRUE;
-
- if( signals & (1L<<signal) )
- {
- Execute (args.name,0,0);
- DeleteFile (args.name);
- }
- }
-
- EndNotify( nr );
- FreeSignal( signal );
- }
- FreeVec (nr);
- }
- else PrintFault( ERROR_NO_FREE_STORE, 0 );
-
- FreeArgs( rdargs );
- }
- else PrintFault( IoErr(), NULL );
-
- return RETURN_OK;
- }
-